import { FormRules } from "element-plus"

export const basicDatumFormRules: FormRules = {
  companyShortName: [
    { required: true, message: "请输入公司简称", trigger: "blur" },
    { min: 2, max: 10, type: "string", message: "公司简称必须在2到10个字符之内", trigger: "blur" }
  ],
  companyName: [
    { required: true, message: "请填写公司全称", trigger: "blur" },
    { min: 6, type: "string", trigger: "blur" }
  ],
  companyDescription: [{ type: "string", message: "请填写公司描述", trigger: "blur" }],
  companyAddress: [{ type: "array", message: "请输入公司地址", required: true, trigger: "change" }],
  companyEmail: [{ type: "string", message: "请输入公司邮箱", trigger: "blur" }],
  companyPhone: [
    { type: "string", required: true, message: "请输入公司联系电话", trigger: "blur" },
    {
      type: "string",
      trigger: "blur",
      validator: (rule, val: string, cb) => {
        const reg = /^1[3-9]\d{9}$/
        if (Number.isInteger(Number(val)) && Number(val) > 0 && val.length === 11 && reg.test(val)) {
          cb()
        } else {
          cb("您输入的手机号码格式不正确，必须是11位的国内手机号")
        }
      }
    }
  ],
  companyLegal: [{ type: "string", message: "请输入公司法人", required: true, trigger: "blur" }],
  companyRegisterCapital: [
    {
      type: "string",
      message: "请输入公司注册资金",
      required: true,
      trigger: "blur",
      validator: (rule, val, cb) => {
        if (Number.isInteger(Number(val)) && Number(val) > 0) {
          cb()
        } else {
          cb("您输入的注册资金格式不正确，必须是正数")
        }
      }
    }
  ],
  companyRegisterDate: [{ type: "date", message: "请输入公司的注册时间", required: true }]
}
